package collection;

import java.util.*;

import javax.print.attribute.HashAttributeSet;

public class AllCol {
	
	public static void main(String[] args) {
		
		List l1 = new ArrayList();
		List l2 = new LinkedList();
		
		Set s1 = new HashSet();
		Set s2 = new TreeSet();
		
		Map m1 = new HashMap();
		Map m2 = new TreeMap();
		
		Map<Data, String> a = new LinkedHashMap<Data, String>(3, .75f);
		a.put(new Data("A"), "1");
		a.put(new Data("AA"), "1");
		a.put(new Data("B"), "1");
		a.put(new Data("ABC"), "1");
		a.put(new Data("BA"), "1");
		a.put(new Data("C"), "1");
		a.put(new Data("DA"), "1");
		a.put(new Data("CA"), "1");
		a.put(new Data("D"), "1");
		a.put(new Data("A"), "2");
		a.put(new Data("B"), "2");
		
		for (Map.Entry<Data, String> entry : a.entrySet()) {
		    Data key = entry.getKey();
		    String value = entry.getValue();
		    
		    System.out.println(key.getName() +" - "+value);
		    
		    // now work with key and value...
		}
		
	}

}

class Data {
	
	String name;
	
	Data(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		return name.length();
	}
	
	@Override
	public boolean equals(Object param) {
		
		if( param instanceof Data) {
			Data d = (Data)param;
			if(this.name == d.name) {
				return true;
			}else {
				return false;
			}
		} else {
			return false;
		}
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}